﻿@using Achievement.Web.Common;
@model Achievement.DataModels.Achievements
@using System.Configuration;
@{
    ViewBag.Title = "成果预览";
}
@section LayoutHeadContainer{
<link rel="stylesheet" type="text/css" href="/css/flexpaper.css" />
<link href="/css/facebox.css" media="screen" rel="stylesheet" type="text/css" />
<style>
.ui-jqgrid .ui-jqgrid-titlebar{ background:#ffffff; display:null;}
.myjqgrid{
    background:#ffffff;
}
.ui-jqgrid tr.jqgrow td {
  white-space: normal !important;
  height:auto;
  vertical-align:text-top;
  padding-top:2px;
  padding-left:20px;
  padding-right:20px;
  font-size:1.2em;
 }
 .ui-jqgrid .ui-state-hover{
 background: #fffff0;
 color:#000000;
 }

 .ui-jqgrid .ui-state-hover a{
 color:#000000;
 }
</style>
<script type="text/javascript" src="/js/flexpaper/flexpaper.js"></script>
<script type="text/javascript" src="/js/flexpaper/flexpaper_handlers.js"></script>
<script src="/scripts/facebox.js" type="text/javascript"></script>
<script>
    $(function () {
        $("#tabs").tabs();
        $("#button").button();
    });
</script>
}
<div id="middle-sdo1">
  <div id="middle">
    <!--Message-->
    <div class="message">北京电力工程公司成果库系统欢迎您！</div>
    <!--Feature Box-->
    <div style="text-align:right;padding-bottom:5px">
    
    </div>
    <div id="tabs" style=" text-align:center">
	    <ul>
		    <li><a href="#tabs-1">成果预览</a></li>
	    </ul>
	    <div id="tabs-1" style="text-align:center; margin-left:auto;">
        <div style=" text-align:center; padding-top:15px; padding-bottom:15px"><h3>@Model.ProjectName</h3><br />
            浏览 @Model.Count 次
        </div>
        <div style=" margin-left:auto; margin-right:auto; text-align:center">
            @{
                string[] imageType = ConfigurationManager.AppSettings["ImageType"].Split(',');
                string[] officType = ConfigurationManager.AppSettings["OfficeType"].Split(',');
                string[] pdfType = ConfigurationManager.AppSettings["PdfType"].Split(',');
                string[] mediaType = ConfigurationManager.AppSettings["MediaType"].Split(',');
                if (officType.Contains(Model.Type) || pdfType.Contains(Model.Type))
                {
                    @: @Html.Partial("ViewFile", Model)
                }
                if (imageType.Contains(Model.Type))
                {
                    @: @Html.Partial("ViewImage", Model)
                }
                if (mediaType.Contains(Model.Type))
                {
                    @: @Html.Partial("ViewMedia", Model)
                }

            }
        </div>
        </div>
        
        <br />
        <br />
        <br />
    </div>
    <div style=" margin-left:auto; margin-right:auto; padding-top:15px">
    <div id="dGrid">
        <div style="text-align:center">
            <table id="list2" style="margin:auto"></table>
        </div>
        <div id="pager2"></div>
    </div>
    @using (Html.BeginForm("AddComment", "Achievement", FormMethod.Post, new { id = "form" }))
    {
        if (UserInfo.ValidataRole(16))
        {
    <table width="100%" style=" margin-left:auto; margin-right:auto; padding-top:15px">
        <tr>
            <td style=" padding:10px 20px 10px 20px"><span style="font-weight:bold;">评分：</span>@Html.TextBox("txtScore", "", new { style = "width:30px", maxlength = "2" })</td>
            <td style="text-align:right;padding-bottom:5px; padding-right:20px">
                
            </td>
        </tr>
        <tr>
            <td style=" padding:20px" colspan="2">
                @Html.TextArea("txtComment", new { style = " height:150px; width:960px" })
                @Html.Hidden("id", Model.ID)
            </td>
        </tr>
        <tr>
            <td style="text-align:right; padding-right:20px;" colspan="2"><button id="button" onclick="$('form').submit()">发表评论</button></td>
        </tr>
    </table>  
        }
    }
    </div>
  </div>
</div>
<script type="text/javascript">

    $('#documentViewer').FlexPaperViewer(
            { config: {
                SWFFile: '@System.Configuration.ConfigurationManager.AppSettings["SavePath"]@Model.DisplayFilePath',
                jsDirectory: '/',
                Scale: 1.0,
                ZoomTransition: 'easeOut',
                ZoomTime: 0.5,
                ZoomInterval: 0.2,
                FitPageOnLoad: true,
                FitWidthOnLoad: false,
                FullScreenAsMaxWindow: false,
                ProgressiveLoading: false,
                MinZoomSize: 0.2,
                MaxZoomSize: 5,
                SearchMatchAll: false,
                InitViewMode: 'Portrait',
                RenderingOrder: 'flash',
                StartAtPage: '',

                ViewModeToolsVisible: true,
                ZoomToolsVisible: true,
                NavToolsVisible: true,
                CursorToolsVisible: true,
                SearchToolsVisible: true,
                WMode: 'window',
                localeChain: 'zh_CN'
            }
            }
    );
    $("#list2").jqGrid({
        url: '/Achievement/commentlist?id=@Model.ID',
        datatype: "json",
        colModel: [
            { name: '', index: 'CID', width: 55, classes: 'myjqgrid', title: false, formatter: CommentFunc },
   	    ],
        rowNum: 10,
        rowList: [10, 20, 30],
        pager: '#pager2',
        sortname: 'CID',
        viewrecords: true,
        sortorder: "desc",
        caption: "成果评价",
        autowidth: true,
        shrinkToFit: true,
        height: 'auto',
        emptyrecords: "暂无数据",
        pgtext: '第{0}页 共{1}页',
        //altRows:true,
        viewsortcols: [false, 'vertical', false],
        recordtext: '第 {0} - {1}条记录 ',
        loadComplete: function (xhr) {
            var rowNum = parseInt($(this).getGridParam("records"), 10);
            if (rowNum <= 0) {
                $("#dGrid").hide();
            }
        } 
    });

    function CommentFunc(cellvalue, options, rowdata) {
        return "<div style='padding-top:15px; padding-bottom:15px'><span style=\"font-weight:bold;\">" + rowdata[6] +
            "</span>@if(UserInfo.ValidataRole(1)){<span style=\"float:right\"><a href='javascript:void(0)' onclick='deletecomment(" + cellvalue + ")'>删除</a></span><span style=\"float:right\"><a href='javascript:void(0)' onclick=\"$.facebox({ ajax: '/Achievement/editcomment?id=" + cellvalue + "'})\">修改</a>&nbsp;&nbsp;&nbsp;</span>}" +
            "</div><div style='padding-top:15px; padding-bottom:15px'>" + 
            rowdata[4] + "</div>";
    }
    $(".ui-jqgrid-htable").hide();

    function deletecomment(id) {
        if (confirm("删除操作不可逆，您确认删除吗？")) {
            window.location.href = "/Achievement/DeleteComment?id=" + id + "&aid=@Model.ID";
        }
    }
</script>